package com.lightsaber.trade.cloth.service.dataimport;

import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springside.modules.orm.Page;

import com.lightsaber.trade.core.dao.BaseDao;
import com.lightsaber.trade.core.service.HppBaseServiceImpl;
import com.lightsaber.trade.cloth.dao.dataimport.DataimportDao;
import com.lightsaber.trade.cloth.entity.dataimport.Dataimport;
import com.lightsaber.trade.cloth.entity.dataimport.DataimportStatus;

@Service
@Transactional
public class DataimportManager extends HppBaseServiceImpl<Dataimport, String> {
    final static Logger log = LoggerFactory.getLogger(DataimportManager.class);

    @Autowired
    DataimportDao dataimportDao;

    @Override
    protected BaseDao<Dataimport, String> getDao() {
        return dataimportDao;
    }

    public Page<Dataimport> findPage(final Dataimport dataimort, final Page<Dataimport> page) {
        return dataimportDao.findPage(dataimort, page);
    }

    @Override
    public void save(final Dataimport dataimport) {
        if (StringUtils.isBlank(dataimport.getId())) {
            dataimport.setStatus(DataimportStatus.Pending);
            super.save(dataimport);
        }
    }

}
